package com.gitee.wsl.io.api

import com.gitee.wsl.prop.AttributeKey

fun < T : Any> ValueReader.get(attributeKey: AttributeKey<T>) = get<T>(attributeKey.name, attributeKey.type)

fun < T : Any> ValueReader.getOrNull(attributeKey: AttributeKey<T>) = getOrNull<T>(attributeKey.name, attributeKey.type)

fun < T : Any> ValueReader.getOrDefault(attributeKey: AttributeKey<T>, default:T): T = getOrNull(attributeKey) ?: default

fun < T : Any> ValueWriter.put(attributeKey: AttributeKey<T>, value: T) = put(attributeKey.name, value)

fun < T : Any> ValueReader.isExits(attributeKey: AttributeKey<T>):Boolean = isExits(attributeKey.name)

inline fun <reified T : Any> ValueContainer.computeIfAbsent(attributeKey: AttributeKey<T>, value : T): T = computeIfAbsent(attributeKey.name,value)

inline fun < reified T : Any> ValueContainer.removeGet(attributeKey: AttributeKey<T>) = removeAndGet<T>(attributeKey.name)

fun ValueContainer.remove(attributeKey: AttributeKey<*>) = remove(attributeKey.name)